package com.gxa.web.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gxa.common.JsonResult;
import com.gxa.service.CustomerService;
import com.gxa.service.impl.CustomerServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/customer_satisfaction/customer_satisfaction")
public class CustomerSatisfactionServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取当前页码和每页显示条数
        Integer currentPage = Integer.parseInt(request.getParameter("page"));
        Integer pageSize = Integer.parseInt(request.getParameter("limit"));
        //调用service
        CustomerService customerService = new CustomerServiceImpl();
        JsonResult jsonResult = customerService.queryCustomerSatisfaction(currentPage, pageSize);
        //响应jsonResult
        response.setContentType("application/json;charset=UTF-8");
        response.getWriter().write(JSONObject.toJSONString(jsonResult));
    }
}
